﻿@model GameCode.Models.Admin.BaseModel
<link href="@Url.Content("~/Scripts/uploadify/uploadify.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/uploadify/swfobject.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/uploadify/jquery.uploadify.v2.1.4.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    var hasRun = false;
    var i = 0;

    $(document).live('pageshow', function (event, ui) {
        i++;
        var isReturn = $(".isReturn").val();
        if (isReturn == 'true' && i == 1) {
            return;
        }
        if (hasRun) {
            return;
        }

        $("#uploadify1").uploadify({
            'uploader': '@Url.Content("~/Scripts/uploadify/uploadify.swf")',
            'script': '@Url.Content("~/Admin/UploadHandle")',
            'cancelImg': '@Url.Content("~/Scripts/uploadify/cancel.png")',
            'folder': 'upload_files',
            'queueID': 'fileQueue',
            'auto': false,
            'multi': false,
            'wmode': 'transparent',
            'sizeLimit': 10737418240,
            'onComplete': function (e, queueId, fileObj, response, data) {
                $(".input_url1").val("/upload_files/" + fileObj.name);
                $("#urll").val("/upload_files/" + fileObj.name);
                parent.reloadImg("/upload_files/" + fileObj.name);
            },
            'onError': function (a, b, c, d) {
                if (d.status == 404)
                    alert('Could not find upload script. Use a path relative to: ' + '<?= getcwd() ?>');
                else if (d.type === "HTTP")
                    alert('error ' + d.type + ": " + d.status);
                else if (d.type === "File Size")
                    alert(c.name + ' ' + d.type + ' Limit: ' + Math.round(d.sizeLimit / 1024) + 'KB');
                else
                    alert('error ' + d.type + ": " + d.text);
            }
        });
        hasRun = true;
    });
</script>
@Html.HiddenFor(m => m.IsReturn, new {@class="isReturn" })
<div id="fileQueue">
</div>
<div id="upload_fieldset">
    <input type="file" id="uploadify1" />
    <div id="upload_submit">
    <input type="button" value="上传" data-inline="true" data-mini="true" onclick="$('#uploadify1').uploadifyUpload();" />
    </div>
    <div id="upload_cancel">
    <input type="button" value="取消" data-inline="true" data-mini="true" onclick="$('#uploadify1').uploadifyClearQueue();" />
    </div>
</div>
